<template>
  <div class="layui-layout layui-layout-admin">
    <div class="adminnav1">
      <Pagetop></Pagetop>
    </div>
    <div class="adminnav2">
      <Secondnav urlname="jiesuan"></Secondnav>
    </div>

    <!-- 主体内容 -->
    <div class="layui-body kedou-admin" id="LAY_app_body app">
      <div class="layadmin-tabsbody-item layui-show">
        <div class="pagelist" style="padding:0">
        	<div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
              <li :class="assetsType=='BALANCE_RMB'?'layui-this':''" @click="getdates('BALANCE_RMB')">余额提现申请</li>
              <li :class="assetsType=='BALANCE_CREDIT'?'layui-this':''" @click="getdates('BALANCE_CREDIT')">积分提现申请</li>
              <li :class="assetsType=='BALANCE_GXJ'?'layui-this':''" @click="getdates('BALANCE_GXJ')">共享金提现申请</li>
            </ul>
          </div>
          <div class="pagetop" style="padding-top:30px">
	    			<Search :seadate="searchArr"></Search>			    	
		      </div>
          <div class="layui-card-body">
          		
            <Tables
              :fdate="pdate"
              :result="res"
              height="430"
              :totalCount="totalRows"
              :pageNumber="curindex"
              :fbtn="btn"
            ></Tables>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Pagetop from "../common/pagetop.vue";
import Secondnav from "../common/secondnav.vue";
import Tables from "../common/tables.vue";
import Search from "../common/search.vue";
export default {
  name: "gradelist",
  components: { Pagetop, Secondnav, Tables, Search },
  data() {
    return {
      pdate: [], //表头
      res: "", //内容
      totalRows: "", //总数量
      curindex: 1, //页数
      btn: [], //按钮
      searchArr: [], //搜索
      isShow: false,
      seapram: "",
      assetsType:"BALANCE_RMB",
      type: localStorage.getItem("type"),
    };
  },
  mounted() {
    this.getdate('BALANCE_RMB');
    this.getsearch();
  },
  methods: {
  	getdates:function(type){
  		this.seapram='';
  		this.getdate(type)
  	},
    getdate: function (type) {
      var _this = this;
      if(type){
      	this.assetsType=type;
      }
      else{
      	type=this.assetsType
      }
      var url = "/pay/aapi/v1.9/withdrawal-record";
      if (_this.seapram) {
        var dates = {
          size: pageSize,
          page: _this.curindex,
          sort:'createAt,DESC',
          'assetsType.equals':type
        };
        var res = _this.seapram;
        for (var i = 0; i < res.length; i++) {
          dates[res[i].key + ".equals"] = res[i].val;
        }
      } else {
        var dates = {
          size: pageSize,
          page: _this.curindex,
          sort:'createAt,DESC',
          'assetsType.equals':type
        };
      }
      //alert(url+"//"+JSON.stringify(dates))
      ajaxRequest(dourl(url), "GET", "json", dates, function (ret, err) {
        //alert(url+"//"+JSON.stringify(ret))
        var arr = [];
        arr[0] = [
          { field: "id", title: "ID" },
          { field: "accountName", title: "申请账号"},
          { field: "realName", title: "真实姓名"},
          {
            field: "assetsAmount",
            title: "提现金额 ",
            templet: function (d) {
              return d.assetsAmount  / 100;
            },
          },
          {
            field: "amount",
            title: "实到金额",
            templet: function (d) {
              return d.amount  / 100;
            },
          },
          {
            field: "amount",
            title: "资产申请类型 ",
            templet: function (d) {
              var str=''
              if(d.assetsType =='BALANCE_RMB'){
              	str='余额'
              }
              else if(d.assetsType =='BALANCE_GXJ'){
              	str='共享金'
              }
              else{
              	str='积分'
              }
              return str
            },
          },
          
          { field: "outTradeNo", title: "业务订单号"},
          {
            field: "authStatus",
            title: "提现方式 ",
            templet: function (d) {
              var str=''
              if(d.type =='BALANCE_RMB'){
              	str='资产现金'
              }
              else if(d.type =='PROFITSHARING'){
              	str='微信提现'
              }
              else if(d.type =='OFFLINEPAY'){
              	str='线下打款'
              }
              else{
              	str='转账'
              }
              return str
            },
          },
          {
            field: "authStatus",
            title: "审核状态",
            templet: function (d) {
              var str=''
              if(d.authStatus =='NOTYET'){
              	str='待审核'
              }
              else if(d.authStatus =='PASS'){
              	str='审核通过'
              }
              else if(d.authStatus =='FAIL'){
              	str='审核不通过'
              }
              else{
              	str='已取消'
              }
              return str
            },
          },
          {
            field: "reson",
            title: "驳回原因",
          },
          {
            field: "author",
            title: "审核人 ",
          },
          {
            field: "createAt",
            title: "创建时间 ",
            templet: function (d) {
              return FormatDate(d.createAt)
            }
          },
          {
            field: "right",
            title: "操作",
            width: "250",
            fixed: "right",
            templet: function (d) {
            	var str = ''
            	if(d.authStatus=='NOTYET'){
            		var str = '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="pay">审核</a>';
            	}
		          str=str+'<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="enable">详情</a>';
              return str;
            },
          },
        ];
        _this.pdate = arr;
        _this.res = ret.data.list; //res1;
        _this.totalRows = ret.data.totalRows;
        _this.curindex = ret.data.page + 1;
      });
    },
    getsearch: function () {
      var arr = [{ field: "accountName", title: "申请账号", type: "input" }];
      this.searchArr = arr;
    },
    page: function (index, obj) {
      //alert(JSON,stringify(obj))
      this.curindex = index;
      this.getdate();
    },
    sousuo: function (pram) {
      //alert(JSON.stringify(pram))
      this.seapram = pram;
      this.res = "";
      this.totalRows = "";
      this.curindex = "";
      this.getdate(this.assetsType);
    },
	  payInfo:function(data){
	  	var _this = this;
			layer.open({
        type: 2,
        title: "审核",
        content: baseurl + "/jsconfirm",
        area: _this.screens() < 2 ? ["80%", "65%"] : ["800px", "650px"],
        success: function (layero, index) {
         		var iframeWin = window[layero.find('iframe')[0]['name']];
         		data.byfrom='sqtxlist'
        		iframeWin.getdates(data);
        },
      });
	  },
	  enableInfo:function(data){
    	var _this = this;
			layer.open({
        type: 2,
        title: "查看提现审核详情",
        content: baseurl + "/txdetail",
        area: _this.screens() < 2 ? ["80%", "65%"] : ["800px", "650px"],
        success: function (layero, index) {
         		var iframeWin = window[layero.find('iframe')[0]['name']];
        		iframeWin.getdates(data);
        },
      });
	  },
    screens: function () {
      return screen();
    },
  },
  updated: function () {
    this.isShow = true;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
    });
  },
};
</script>
<style scoped>
/**/
</style>